package com.colinsage.dpap.dao.test;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.colinsage.spring.domain.User;
import com.deppon.foss.framework.server.components.dataaccess.ibatis.iBatis3DaoImpl;


public class IbatisDaoPage extends iBatis3DaoImpl {
	final static Log log = LogFactory.getLog(IbatisDaoPage.class);
	public List<User> findAllUsers() {
		SqlSession session = super.getSqlSession();
		List<User> selectList = session.selectList("myuser.findAll", null, new RowBounds(3, 2));
		return selectList;
	}

	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");

		IbatisDaoPage page = (IbatisDaoPage) ctx.getBean("dao");
		query(page);		
	}

	private static void query(IbatisDaoPage page) {
		List<User> result = page.findAllUsers();
		int i =0;
		for(User u: result){
			i++;
		log.info(u.getId());
		log.info(u.getName());
		log.info(u.getAge());
		log.info(i + " : ----------华丽的分割线----------");
		}
	}
}
